<?php
/**
  * @Author     liangjinying
  * @Date       2015-1-14
  * @Encoding   UTF-8
  * Descript    Please Type In
  **/
class ModGameLoginTrace{
	
	public static function indexData($params, $field){
		
		$table = 'tblGameLoginTrace';
		$where = ' WHERE RecDate BETWEEN :begin AND :end
                        AND Platform=:platform AND GameSrc=:game AND KPI = :kpi AND CID = "ALL" ';
        $args  = array(
            ':begin'    => $params['time_start'],
            ':end'      => $params['time_end'],
            ':platform' => $params['p'],
            ':game'     => $params['g'],
            ':kpi'      => $params['kpi'],
        );
        
        if(!empty($params['server']) && $params['server'] !== 'ALL' && $params['server'] !== 'LIST'){
        	$where .= 'AND SID=:server';
        	$args[':server'] = $params['server'];
        }else if($params['server'] == 'LIST'){
        	$where .= 'AND SID in (:server)';
        	$args[':server'] = PubBase::getAllServer($params['p'], $params['g']);
        }else{
        	$where .= 'AND SID = "ALL"';
        }
        
        $field = implode(',', $field);
        
        $sql = "SELECT {$field} FROM {$table} {$where}";
        
        $dbLink = new PubDbLink('dbSelf', PubDatabase::getMgmtDbName($params['p'], $params['g']));
        
        return $dbLink->query($sql, $args);
		
	}
	 
}